package com.pzhu.filter;


import com.pzhu.controller.UserController;
import com.pzhu.controller.impl.BookControllerImpl;
import com.pzhu.controller.impl.UserControllerImpl;

import javax.servlet.*;
import java.io.IOException;

public class RegisterFilter implements Filter {
    UserController userController = new UserControllerImpl();

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        Long lastId = userController.selectLastUserId();
        servletRequest.setAttribute("lastId",lastId+1);
        System.out.println(lastId);
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
